<template>
  <div class="computed-a">
    <h1>ComputedA</h1>
    <button @click="handleClick">点击分数</button>
    <p>分数{{score}}</p>
  </div>
</template>

<script>
export default {
  name: "ComputedA",
  // 通过计算属性获取 state中的score
  computed: {
    score() {
      // 获取state中的score数据
      return this.$store.getters.currentScore;
    }
  },
  methods: {
    // 事件处理函数
    handleClick() {
      // 触发actions中的touchScore事件
      this.$store.dispatch('touchScore');
    }
  }
}
</script>

<style scoped>

</style>